package com.fitbet.api.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.demo2do.core.persistence.GenericDaoSupport;
import com.demo2do.core.persistence.annotation.Dao;
import com.fitbet.api.dao.WalletDao;
import com.fitbet.api.service.WalletService;
import com.fitbet.entity.user.User;
import com.fitbet.entity.user.Wallet;

/**
 * 
 * @author LZJ
 *
 */
@Service("walletService")
public class WalletServiceImpl implements WalletService {
	
	@Autowired
    private GenericDaoSupport genericDaoSupport;
	
	@Dao
	private WalletDao walletDao;
	

	/*
	 * (non-Javadoc)
	 * @see com.fitbet.wechat.service.WalletService#loadWallet(com.fitbet.entity.user.User)
	 */
	public Wallet loadWallet(String unionid) {


		User user = genericDaoSupport.searchForObject("FROM User WHERE disabled = false AND unionid = :unionid", "unionid", unionid, User.class);
		
		Wallet wallet = walletDao.loadWallet(user);
		
		return wallet;
	}


}
